package org.edu.modules.jxzy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.edu.modules.jxzy.entity.JwJiaoshi;
import org.edu.modules.jxzy.entity.JwKecheng;
import org.edu.modules.jxzy.mapper.JwKechengMapper;
import org.edu.modules.jxzy.service.IJwKechengService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;

/**
 * @Description: 教务课程信息
 * @Author: jeecg-boot
 * @Date:   2021-04-15
 * @Version: V1.0
 */
@Service
public class JwKechengServiceImpl extends ServiceImpl<JwKechengMapper, JwKecheng> implements IJwKechengService {

    @Override
    public void updateStatusByIds(String ids, int status) {
        List<String> list = Arrays.asList(ids.split(","));
        for (String str:list) {
            baseMapper.updateById(new JwKecheng().setId(Integer.parseInt(str)).setStatus(status));
        }
    }

    @Override
    public int queryCount() {
        LambdaQueryWrapper<JwKecheng> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(JwKecheng::getIsdelete, 0);
        return this.count(wrapper);
    }

    @Override
    public int queryCountByZyzIdAndKcxz(Integer zyzId, Integer kcxz) {
        LambdaQueryWrapper<JwKecheng> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(JwKecheng::getFalid, zyzId);
        if(kcxz != null){
            wrapper.eq(JwKecheng::getKcxz, kcxz);
        }
        wrapper.eq(JwKecheng::getIsdelete, 0);
        return this.count(wrapper);
    }
}
